import java.util.HashMap;
import java.util.Scanner;

public class StudentGrades {

    private HashMap<String, Integer> grades = new HashMap<>();
//记录学生成绩

    public void recordGrade(String name, int score) {
        grades.put(name, score);
        System.out.println("成绩已记录：" + name + " - " + score);
    }
//查询学生成绩

    public void queryGrade(String name) {
        if (grades.containsKey(name)) {
            System.out.println(name + " 的成绩是：" + grades.get(name));
        } else {
            System.out.println("未找到 " + name + " 的成绩");
        }
    }

    public static void main(String[] args) {
        StudentGrades studentGrades = new StudentGrades();
        Scanner scanner = new Scanner(System.in);

        studentGrades.recordGrade("Alice", 95);
        studentGrades.recordGrade("Bob", 88);

        studentGrades.queryGrade("Alice");
        studentGrades.queryGrade("Bob");
        studentGrades.queryGrade("Charlie");

        while (true) {
            System.out.println("\n请选择操作：");
            System.out.println("1. 记录成绩");
            System.out.println("2. 查询成绩");
            System.out.println("3. 退出");
            System.out.print("请输入选项：");
            int choice = scanner.nextInt();
            scanner.nextLine();

            switch (choice) {
                case 1:
                    System.out.print("请输入学生姓名：");
                    String name = scanner.nextLine();
                    System.out.print("请输入学生成绩：");
                    int score = scanner.nextInt();
                    studentGrades.recordGrade(name, score);
                    break;
                case 2:
                    System.out.print("请输入要查询的学生姓名：");
                    String queryName = scanner.nextLine();
                    studentGrades.queryGrade(queryName);
                    break;
                case 3:
                    System.out.println("退出程序。");
                    scanner.close();
                    return;
                default:
                    System.out.println("无效选项，请重新选择。");
            }
        }
    }
}